<%@ page language="java" pageEncoding="utf-8" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>系统日志明细</title>
    <jsp:include page="/IncludeJS.jsp"></jsp:include>
</head>
<body>
<script type="text/javascript">
    $(function () {
        var pager = $(".easyui-datagrid").datagrid('getPager');
        $(pager).pagination({
            total:${pager.totalRows},
            pageSize:${pager.pageRow},
            displayMsg: '{from}-{to}/{total}',
            pageNumber:${pager.cur_page},
            afterPageText: '页，共{pages}页',
            pageList: [100, 500, 1000, 10000],
            loading: false,
            showPageList: true,
            showRefresh: true,
            //刷新方法
            onBeforeRefresh: function (p, s) {
                location.href = "${pageContext.request.contextPath }/log/list?cur_page=" + p + "&pageRow=" + s;
            },
            onSelectPage: function (p, s) {
                location.href = "${pageContext.request.contextPath }/log/list?cur_page=" + p + "&pageRow=" + s;
            }
        });
        $('#changesize').datagrid('resize', {
            height: document.body.clientHeight - 30
        });
        init();
    });

    function init() {
        var sd = "${log.sdate}";
        var ed = "${log.edate}";
        var idx = sd.indexOf(' ');
        sd = sd.substring(0, idx);
        idx = ed.indexOf(' ');
        ed = ed.substring(0, idx);
        if (sd != '') {
            $("#ssdate").datebox("setValue", sd);
            $("#eedate").datebox("setValue", ed);
        } else {
            var d = new Date();
            var y = d.getFullYear();
            var m = d.getMonth() + 1;
            var d = d.getDate();
            $("#ssdate").datebox("setValue", y + "-" + m + "-01");
            $("#eedate").datebox("setValue", y + "-" + m + "-" + d);
        }
    }

    function check() {
        if ($("#ssdate").datebox("getValue") != '') {
            $("#sdate").val($("#ssdate").datebox("getValue") + " 00:00:00");
            $("#edate").val($("#eedate").datebox("getValue") + " 23:59:59");
        }
    }

    function setoprtype(flag) {
        $("#oprtype").val(flag);
    }
</script>
<table width="100%" border="0" cellpadding="0" cellspacing="0" BACKGROUND="images/maintitle.jpg" class="tablelist2">
    <form action="${pageContext.request.contextPath }/log/list" method="post" onsubmit="check();">
        <input type="hidden" name="sdate" id="sdate">
        <input type="hidden" name="edate" id="edate">
        <tr class="tableselect2">
            <td align="right">
                管理员姓名：<input type="text" name="userName" id="userName" style="width:100px"
                             value="${log.userName}"></input>
                日志类型：
                <select name="logType" id="logType" style="width:100px">
                    <option value="0">---不选---</option>
                    <c:forEach items="${logTypes}" var="v" varStatus="st">
                        <c:if test="${log.logType == (st.index+1)}">
                            <option value="${st.index+1}" selected="selected">${v }</option>
                        </c:if>
                        <c:if test="${log.logType != (st.index+1)}">
                            <option value="${st.index+1}">${v }</option>
                        </c:if>
                    </c:forEach>
                </select>
                日志内容：<input type="text" name="content" id="content" style="width:100px" value="${log.content}"></input>
                时间：<input type="text" name="ssdate" id="ssdate" class="easyui-datebox"/>
                到<input type="text" name="eedate" id="eedate" class="easyui-datebox"/>
                <input type="submit" value="查询">
            </td>
        </tr>
    </form>
</table>
<table class="easyui-datagrid" pagination="true" id="changesize" style="width:auto;padding:0px" singleSelect="false">
    <thead>
    <tr>
        <th field="id" width=50 align="center">编号</th>
        <th field="createDate" width=150 align="center">操作日期</th>
        <th field="userName" width=60 align="center">管理员</th>
        <th field="ipAddress" width=100 align="center">IP地址</th>
        <th field="logTypes" width=60 align="center">操作类型</th>
        <th field="content" width=800 align="center">操作内容</th>
    </tr>
    </thead>
    <tbody>
    <c:forEach items="${pager.data}" varStatus="i" var="v">
        <tr>
            <td>${i.index+1 }</td>
            <td>${v.createDate }</td>
            <td>${v.userName }</td>
            <td>${v.ipAddress }</td>
            <td>${v.logTypes }</td>
            <td>${v.content }</td>
        </tr>
    </c:forEach>
    </tbody>
</table>
</body>
</html>